<?php

use think\migration\Migrator;
use think\migration\db\Column;

class DealerGoods extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('dealer_goods', ['comment' => '经销商商品表']);
        $table->addColumn('dealer_id', 'integer', ['comment' => '经销商id'])
              ->addColumn('company_id', 'integer', ['comment' => '公司id'])
              ->addColumn('goods_id', 'integer', ['comment' => '标品id'])
              ->addColumn('brand_id', 'integer', ['comment' => '品牌id'])
              ->addColumn('cate_id', 'integer', ['comment' => '分类id'])
              ->addColumn('dealer_cate_id', 'integer', ['comment' => '经销商分类id'])
              ->addColumn('dealer_brand_id', 'integer', ['comment' => '经销商品牌id'])
              ->addColumn('code69', 'string', ['limit' => 255, 'default' => '', 'comment' => '69码', 'collation' => 'utf8mb4_general_ci'])
              ->addColumn('name', 'string', ['limit' => 255, 'default' => '', 'comment' => '商品名称', 'collation' => 'utf8mb4_general_ci'])
              ->addColumn('image', 'string', ['limit' => 255, 'default' => '', 'comment' => '商品图片', 'collation' => 'utf8mb4_general_ci'])
              ->addColumn('shelf_life_day', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '保质期(天)', 'signed' => false])
              ->addColumn('warehouse_warn_day', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '入库预警(天)', 'signed' => false])
              ->addColumn('retention_warn_day', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '滞留预警(天)', 'signed' => false])
              ->addColumn('expiration_warn_day', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '过期预警(天)', 'signed' => false])
              ->addColumn('storage_condition', 'string', ['limit' => 255, 'default' => '', 'comment' => '存储条件', 'collation' => 'utf8mb4_general_ci'])
              ->addColumn('virtual_sales', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '虚拟销量', 'signed' => false])
              ->addColumn('actual_sales', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '实际销量', 'signed' => false])
              ->addColumn('stock', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '库存', 'signed' => false])
              ->addColumn('status', 'integer', ['limit' => 11, 'default' => 1, 'comment' => '状态：1启用 2禁用', 'signed' => false])
              ->addColumn('remark','string',['limit' => 255, 'default' => '', 'comment' => '备注'])
              ->addColumn('create_time', 'integer', ['default' => null, 'limit' => 11, 'comment' => '创建时间'])
              ->addColumn('update_time', 'integer', ['default' => null, 'limit' => 11, 'comment' => '更新时间'])
              ->addColumn('delete_time', 'integer', ['default' => null, 'limit' => 11, 'comment' => '删除时间'])
              ->addIndex('goods_id', ['name' => 'idx_goods_id'])
              ->addIndex('dealer_id', ['name' => 'idx_dealer_id'])
              ->addIndex('company_id', ['name' => 'idx_company_id'])
              ->addIndex('brand_id', ['name' => 'idx_brand_id'])
              ->addIndex('cate_id', ['name' => 'idx_category_id'])
              ->addIndex('dealer_cate_id', ['name' => 'idx_dealer_cate_id'])
              ->addIndex('dealer_brand_id', ['name' => 'idx_dealer_brand_id'])
              ->addIndex('code69', ['name' => 'idx_code69'])
              ->create();

    }
}
